package com.example.argumentresolver.controller;

import com.example.argumentresolver.config.UserId;
import com.example.argumentresolver.vo.UserInfo;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/user")
public class UserController {

    /**
     * 参数没有注解，不执行任何HandlerMethodArgumentResolver
     * @param userInfo
     * @param addr
     * @return
     */
    @GetMapping("/info")
    public UserInfo getUserInfo(UserInfo userInfo, String addr, Integer age) {
        return userInfo;
    }

    @GetMapping("/info1")
    public UserInfo getUserInfo1(@UserId UserInfo userInfo) {
        return userInfo;
    }

    @PostMapping("/saveUserInfo")
    public UserInfo saveUserInfo(@RequestBody UserInfo userInfo) {
        return userInfo;
    }

    // RequestParamMapMethodArgumentResolver解析参数
    @GetMapping("/info3")
    public Map getUserInfo3(@RequestParam Map<String, Object> map) {
        return map;
    }
}